//
//  AccountInformationViewController.m
//  阿帕
//
//  Created by mac on 2020/1/2.
//  Copyright © 2020 GCY. All rights reserved.
//

#import "AccountInformationViewController.h"
#import "WithdrawApplyViewController.h"
#import "TradeRecordsViewController.h"
#import "WithdrawalTabBar.h"

@interface AccountInformationViewController ()
@property (weak, nonatomic) IBOutlet UIView *buleBgView;
@property (weak, nonatomic) IBOutlet UILabel *balanceLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *blueBgView_height;
@property (weak, nonatomic) IBOutlet UILabel *tipTextLabel;

@end

@implementation AccountInformationViewController

static const CGFloat itemHeight = 45;

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self baseViewLayout];
}

- (void)baseViewLayout {
        
    self.navigationItem.title = @"账户信息";
    
    _buleBgView.backgroundColor = Theme_ColorValue;
    _tipTextLabel.textColor = Dark_TextColor;
    
    NSDictionary *branch = [UserDefaultUtil valueForKey:Login_Branch];
//    if ([self.typeStr intValue] == 0) {
//        _balanceLabel.text = CJStringWithFormat(@"%.2f", [branch[@"pufaBalance"] floatValue]);
//    }else if ([self.typeStr intValue] == 1){
//        _balanceLabel.text = CJStringWithFormat(@"%.2f", [branch[@"hatBalance"] floatValue]);
//    }else if ([self.typeStr intValue] == 2){
//        _balanceLabel.text = CJStringWithFormat(@"%.2f", [self.dataDic[@"balance"] floatValue]);
//    }
    _balanceLabel.text = CJStringWithFormat(@"%.2f", [self.dataDic[@"balance"] floatValue]);

    NSArray *titleArr = @[@"交易记录", @"提现申请", @"提现记录"];
    NSArray *iconArr = @[@"gcy_icon_my_index5", @"gcy_icon_acci_txsq", @"gcy_icon_acci_jyjl"];
    
    for (int i=0; i<titleArr.count; i++) {
    
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, _buleBgView.bottom + itemHeight*i, ScreenW, itemHeight)];
        bgView.userInteractionEnabled = YES;
        [bgView nyl_addTapGes:^{
            if (i==1) {
                WithdrawApplyViewController *wavc = [[WithdrawApplyViewController alloc] init];
                float balance = 0.00;
//                if ([self.typeStr intValue] == 1) {
//                    balance = [branch[@"pufaBalance"] floatValue];
//                }else if([self.typeStr intValue] == 1){
//                    balance = [branch[@"hatBalance"] floatValue];
//                }else if ([self.typeStr intValue] == 2){
//                    balance = [branch[@"gdBalance"] floatValue];
//                }
                balance = [self.dataDic[@"balance"] floatValue];
                if (balance > 0) {
                    wavc.balanceFloat = balance;
                }
                wavc.accountType = self.typeStr;
                wavc.dataDic = self.dataDic;
                [self.navigationController pushViewController:wavc animated:YES];
            } else if (i==0) {
                TradeRecordsViewController *trvc = [[TradeRecordsViewController alloc] init];
                trvc.accountType = self.typeStr;
                trvc.dataDic = self.dataDic;
                [self.navigationController pushViewController:trvc animated:YES];
            } else {
                WithdrawalTabBar *wtvc = [[WithdrawalTabBar alloc] init];
                    wtvc.accountType = self.typeStr;
                wtvc.dataDic = self.dataDic;
                [self.navigationController pushViewController:wtvc animated:YES];
            }
        }];
        [self.view addSubview:bgView];
        
        UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(18, 12.5f, 20, 20)];
        icon.image = image(iconArr[i]);
        [bgView addSubview:icon];
        
        UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(icon.cy_right + 10, 0, 200, itemHeight)];
        textLabel.text = titleArr[i];
        textLabel.textColor = Dark_TextColor;
        textLabel.font = font(16);
        textLabel.adjustsFontSizeToFitWidth = YES;
        [bgView addSubview:textLabel];
        
        UIImageView *arrow = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenW-30, 17, 6, 11)];
        arrow.image = image(@"gcy_icon_hd_rarrow");
        [bgView addSubview:arrow];
        
        //分割线
        UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(15, itemHeight-1, ScreenW - 30, 1)];
        hLine.backgroundColor = BackgroundColor;
        [bgView addSubview:hLine];
    }
}

@end
